package main.katalog.model;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.PreparedStatement;


public class connection {
	  private Connection connect = null;
	  private Statement statement = null;
	  private PreparedStatement preparedStatement = null;
	  private ResultSet resultSet = null;

	  public connection() throws Exception{
		  try {
			  // This will load the MySQL driver, each DB has its own driver
			  Class.forName("com.mysql.jdbc.Driver");
			  // Setup the connection with the DB
			  connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/catalog?user=root&password=&useUnicode=true&characterEncoding=UTF-8");
		  } catch (Exception e) {
			  throw e;
		  } 
	  }
	  public void close() throws SQLException{
		  if(resultSet!=null)
			  resultSet.close();
		  if(statement!=null)
			  statement.close();
		  if(connect!=null)
			  connect.close();
	  }


	  public Connection getConnect() {
		  return connect;
	  }

	public void setConnect(Connection connect) {
		this.connect = connect;
	}

	public Statement getStatement() {
		return statement;
	}

	public void setStatement(Statement statement) {
		this.statement = statement;
	}

	public ResultSet getResultSet() {
		return resultSet;
	}

	public void setResultSet(ResultSet resultSet) {
		this.resultSet = resultSet;
	}


	public PreparedStatement getPreparedStatement() {
		return preparedStatement;
	}


	public void setPreparedStatement(PreparedStatement preparedStatement) {
		this.preparedStatement = preparedStatement;
	}
}